package com.example.springbootdemo.conditional;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 测试注解 ConditionalOnMissingBean
 */
@Configuration
public class BeanConfig {

    @Bean
    public DemoC demoC1() {
        System.out.println("loadBean ----> demoC1");
        return new DemoC();
    }

    @Bean
    @ConditionalOnMissingBean(DemoC.class)
    public DemoC demoC2() {
        System.out.println("loadBean ----> demoC2");
        return new DemoC();
    }


}
